* Load data
use "$data/main_touse.dta", clear


* Table 1 Results; replicated here but not saved as separate xls file.
* Loop over variables
foreach x in patience_ctb_trim {
di "BEGIN: ***************** VARIABLE: `x'`t' *****************"
* Median, mean, N
bysort ctb: tabstat `x', s(median mean N)
* Differences in means, t-test
di "Results of t-test: `x': Benchmark against ctblottery_D"
ttest `x', by(ctblottery_D) unequal
di "Results of t-test: `x': Benchmark against ctbhyplow_D"
ttest `x', by(ctbhyplow_D) unequal
di "Results of t-test: `x': Benchmark against ctbhyphi_D"
ttest `x', by(ctbhyphi_D) unequal

di "Results of t-test: `x': CTB Lottery against ctblottery_hypolow_D"
ttest `x', by(ctblottery_hypolow_D) unequal
di "Results of t-test: `x': CTB Lottery against ctblottery_hypohigh_D"
ttest `x', by(ctblottery_hypohigh_D) unequal

di "Results of t-test: `x': CTB Hypothetical Low against hypohigh_D"
ttest `x', by(ctbhypolow_hypohigh_D) unequal

* KS tests
di "`x': ctblottery_D"
ksmirnov `x', by(ctblottery_D) 
di "`x': ctbhyplow_D"
ksmirnov `x', by(ctbhyplow_D) 
di "ctbhyphi_D"
ksmirnov `x', by(ctbhyphi_D) 

di "`x': ctblottery_hypolow_D"
ksmirnov `x', by(ctblottery_hypolow_D) 
di "`x': ctblottery_hypohigh_D"
ksmirnov `x', by(ctblottery_hypohigh_D)
 
di "`x': ctbhypolow_hypohigh_D"
ksmirnov `x', by(ctbhypolow_hypohigh_D)
di "END: ***************** VARIABLE: `x' *****************" 
	}

* Table 1 continued
* KS tests and Levene’s Test
* Compare trimmmed benchmark ctb vs. lottery
robvar patience_ctb_trim if ctb==1 | ctb==2, by(ctb)
* Compare benchmark ctb vs. hypo low
robvar patience_ctb_trim if ctb==1 | ctb==3, by(ctb)
* Compare benchmark ctb vs. hypo high
robvar patience_ctb_trim if ctb==1 | ctb==4, by(ctb)

* Compare trimmmed lottery vs. hypo low
robvar patience_ctb_trim if ctb==2 | ctb==3, by(ctb)
* Compare trimmmed lottery ctb vs. hypo high
robvar patience_ctb_trim if ctb==2 | ctb==4, by(ctb)

* Compare trimmmed hypo low vs. hypo high
robvar patience_ctb_trim if ctb==3 | ctb==4, by(ctb)

